<template>
	<view>
		<uni-nav-bar statusBar :border='false' color="#fff" fixed :backgroundColor='backgroundColor'>
			<block slot="left">
				<view class="flex-row-flex-start">
					<image class="logo" src="/static/common/logo.png" mode=""></image>
					<view class="topTitle">
						猩猩地堡
					</view>

				</view>
			</block>
		</uni-nav-bar>
		<view class="topView">
			<view class="" style="margin-top: 40rpx;">
			<picker mode="date" fields='month' :value="create_month" @change="bindDateChange">
				<view class="screeningView flex-row-flex-start" style="margin-left: 30rpx;">
					<view class="screening" style="margin-right: 6rpx;">
						{{create_month}}
					</view>
					<u-icon name="arrow-down-fill" color="#333333" size="14"></u-icon>
				</view>
			</picker>
				<view v-for="(item,index) in list" :key="index">
					<view class="item ">
						<view class="time">
							{{item.create_time}}
						</view>
						<view class="line" style="margin-top: 30rpx;">

						</view>

						<view class="flex-row-space-between" style="margin-top: 30rpx;">
							<view class="left">
								打卡位置
							</view>
							<view class="right">
								{{item.sign_address}}
							</view>
						</view>
						<view class="flex-row-space-between" style="margin-top: 30rpx;">
							<view class="left">
								打卡时间
							</view>
							<view class="right">
								{{item.create_time}}
							</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 		<view class="" style="margin-top: 30rpx;">
				<view v-for="(item,index) in list1" :key="index">
					<view class="dkTime">
						昨天 19:01
					</view>
					<view v-for="(item1,index1) in 2" :key="index1">
						<view class="dkItem">
							<view class="dkTitle">
								打卡结果
							</view>
							<view class="line">

							</view>
							<view class="flex-row-flex-start" style="margin-top: 30rpx;">
								<image class="error" src="/static/record/error.png" mode=""></image>
								<view class="">
									<view class="dkName">
										张三 18:01 离岗
									</view>
									<view class="dkPhone">
										15987596666
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view> -->

			<view class="" style="height: 300rpx;">

			</view>
		</view>
		<u-tabbar  :safeAreaInsetBottom="true" :zIndex='999' activeColor='#157EFE' inactiveColor='#999999'
			:value="2" :fixed="true" :placeholder="true">
			<u-tabbar-item text="签到" @click="tabbarClick" :name='1'>
				<image class="u-page__item__slot-icon" slot="active-icon" src="/static/tabbar/2.png"></image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="/static/tabbar/1.png"></image>
			</u-tabbar-item>
			<u-tabbar-item text="记录" @click="tabbarClick" :name='2'>
				<image class="u-page__item__slot-icon" slot="active-icon" src="/static/tabbar/6.png"></image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="/static/tabbar/5.png"></image>
			</u-tabbar-item>
			<u-tabbar-item text="我的" @click="tabbarClick" :name='3'>
				<image class="u-page__item__slot-icon" slot="active-icon" src="/static/tabbar/8.png"></image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="/static/tabbar/7.png"></image>
			</u-tabbar-item>
		</u-tabbar>


	</view>
</template>

<script>
	import {
		mapActions,
		mapState
	} from "vuex";
	import {
		signList,
	} from '@/api/index.js'
	export default {
		components: {},
		computed: {

		},
		data() {
			return {
				create_month:'',
				list: [],
				list1: [
					
				],
				title: "",
				backgroundColor: 'ffffff00',
				data: {}

			}
		},
		computed: {
			...mapState([
				'baseColor'
			]),
		},
		onPageScroll(e) {
			if (e.scrollTop > 20) {
				this.backgroundColor = "#AED0FC"
			} else {
				this.backgroundColor = "#ffffff00"
			}
		},
		onShow() {
			this.create_month=this.getCurrentDate()
			this.loadData()
		},
		onLoad(e) {

		},
		//下拉刷新
		onPullDownRefresh() {


		},
		//加载更多
		onReachBottom() {

		},
		onPageScroll(e) {
			// if (e.scrollTop > 20) {
			// 	this.backgroundColor = "#FBF9FF"
			// } else {
			// 	this.backgroundColor = "#ffffff00"
			// }
		},
		methods: {
			bindDateChange(e){
				console.log(e)
				this.create_month=e.detail.value
				this.loadData()
			},
			getCurrentDate() {
			    const now = new Date();
			    const year = now.getFullYear();
			    const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始，需要+1
			    const day = String(now.getDate()).padStart(2, '0');
			    
			    return `${year}-${month}`;
			},
			tabbarClick(e) {
				if (e == 1) {
					uni.reLaunch({
						url: '/pages/index/index'
					})
				}
				if (e == 2) {
					uni.reLaunch({
						url: '/pages/record/record'
					})
				}
				if (e == 3) {
					uni.reLaunch({
						url: '/pages/my/my'
					})
				}
			},
			loadData() {

				var data = {
					page: 1,
					page_size: 999,
					create_month:this.create_month
				}
				signList(data).then(res => {
					this.list = res.data.data
				})
			},


		}
	}
</script>

<style lang="scss">
	.moon {
		margin-left: 32rpx;
		font-weight: bold;
		font-size: 32rpx;
		color: #333333;
	}

	.item {
		margin: 32rpx;
		padding: 30rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.time {
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #333333;
	}

	.left {
		font-weight: 500;
		font-size: 28rpx;
		color: #777777;
	}

	.right {
		font-weight: 500;
		font-size: 28rpx;
		color: #333333;
	}

	.dkTime {
		text-align: center;
		font-weight: 500;
		font-size: 24rpx;
		color: #999999;
	}

	.dkItem {
		margin: 30rpx;
		padding: 30rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.dkTitle {
		font-weight: 400;
		font-size: 26rpx;
		color: #999999;
		margin-bottom: 20rpx;
	}

	.error {
		margin-right: 20rpx;
		width: 56rpx;
		height: 56rpx;
	}

	.dkName {
		font-weight: bold;
		font-size: 32rpx;
		color: #333333;
	}

	.dkPhone {
		margin-top: 6rpx;
		font-weight: 500;
		font-size: 28rpx;
		color: #33333380;
	}
</style>